package com.normal.main.activity

import android.os.Bundle
import com.didi.drouter.annotation.Router
import com.normal.main.databinding.ActivityRoomBinding
import com.normal.zbase.impl.arouter.DRouterPath
import com.normal.zbase.impl.base.BaseActivity
import com.normal.zbase.impl.tools.extend.click
import com.normal.zbase.impl.tools.extend.logger
import com.normal.zbase.impl.tools.utils.JsonUtils
import com.zxy.zxyroom.database.commonDataBase
import com.zxy.zxyroom.empty.StudentBean
import com.zxy.zxyroom.empty.TearchBean
@Router(path = DRouterPath.Path.APP_ROOM)
class RoomActivity : BaseActivity<ActivityRoomBinding>() {

    override fun viewBinding(): ActivityRoomBinding {
       return ActivityRoomBinding.inflate(layoutInflater)
    }

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        viewBinding.btn1.click {
            commonDataBase.teacherDao().insert(TearchBean(tearchId=1,tearchName="张老师"))
            commonDataBase.teacherDao().insert(TearchBean(tearchId=2,tearchName="王老师"))
            commonDataBase.studentDao().insert(StudentBean(studentId = 1,studentName="王二", tearchId = 1))
            commonDataBase.studentDao().insert(StudentBean(studentId = 2,studentName="李四", tearchId = 1))
            commonDataBase.studentDao().insert(StudentBean(studentId = 3,studentName="狗子", tearchId = 2))
        }
        viewBinding.btn2.click {
            val list = commonDataBase.teacherDao().queryTearchWithStudent()
            logger.info(JsonUtils.toJson(list))
        }
    }
}